//
//  GRBargainSuccView.m
//  YC_GRice
//
//  Created by luojinrong11 on 2019/4/16.
//  Copyright © 2019年 YeCai. All rights reserved.
//

#import "GRBargainSuccView.h"

@interface GRBargainSuccView ()
@property(nonatomic,copy)CompleteBlock completeBlock;

@property (weak, nonatomic) IBOutlet UIButton *whiteBt;

@end

@implementation GRBargainSuccView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(void)awakeFromNib{
    [super awakeFromNib];
    [self.whiteBt.layer setBorderWidth:1];
    [self.whiteBt.layer setBorderColor:[HEXCOLOR(0xFE580D)CGColor]];
}

+(instancetype)shareBargainView{
    static  GRBargainSuccView * barginView = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        barginView = [GRBargainSuccView xx_instantiateFromNib];
    });
    return barginView;
}

-(void)showbarginPrice:(CGFloat )barginPrice CompleteBlock:(CompleteBlock)completeBlock{
    self.completeBlock = completeBlock;
    self.barginPriceLabel.text = [NSString stringWithFormat:@"￥%.2lf",barginPrice];
    UIWindow * window = [UIApplication sharedApplication].keyWindow;
    [window addSubview:self];
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(window);
    }];
}
- (IBAction)hiddenView:(id)sender {
    [self removeFromSuperview];
}


- (IBAction)barginAction:(UIButton *)sender {
    [self removeFromSuperview];
    if (self.completeBlock != nil) {
            self.completeBlock();
    }
}

@end
